var mysql = require("mysql");

var DbOptions = {
    host: "localhost",
    user: "root",
    password: "",
    database:"personnel"
}

var connect = function (con) {
    con.connect(function(err){
        if(err){
            console.log('--------------------------------------------------------------')
            console.log('连接数据库失败');
            return;
        }
        console.log('--------------------------------------------------------------')
        console.log('连接数据库成功');
    });
}

var getCon = function () {
    return mysql.createConnection(DbOptions)
}

var close = function (con) {
    con.end(function (err) {
        if(err)
            throw err
        console.log('--------------------------------------------------------------')
        console.log("关闭数据库")
    })
}
exports.connect = connect
exports.close = close
exports.getCon = getCon